package com.storm.future.processor;

import com.storm.future.annotation.NoAttack;
import com.storm.future.red.common.EngineerSoldier;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.stereotype.Component;

/**
 * @author gu
 * @date 2020/3/16 17:17
 */
@Component
public class NoAttackPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        NoAttack annotation = AnnotationUtils.findAnnotation(bean.getClass(), NoAttack.class);
        if(annotation != null && bean instanceof EngineerSoldier){
            EngineerSoldier soldier = (EngineerSoldier)bean;
        }
        return bean;
    }
}
